<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script> 
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>  	
  </head>
  
  <body>
  <div class="mainContainer">
    <div class="headerTitle">日常信息管理&nbsp;>>&nbsp;资产入库管理</div>
       <div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局',"getAllWarehonseAssetCard.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "queryAssetInTree.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
		</div>
     	<div class="dataDivLeftHasTree">	
     	<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td>
					<s:if test="accessRight.indexOf('V')!=-1">
						<input type="button" style="margin-left:2px;" value="刷新" onclick="refresh();"/>
						<input type="button" style="margin-left:2px;" value="明细" onclick="particular();" />
					</s:if>
					<s:if test="accessRight.indexOf('N')!=-1">
						<input type="button" style="margin-left:2px;" value="经办确认" onclick="validate();" />
					</s:if>
					<s:if test="accessRight.indexOf('R')!=-1">
						<input type="button" style="margin-left:2px;" value="经办上报" onclick="report();" />
					</s:if>
					<s:if test="accessRight.indexOf('A')!=-1">
						<input type="button" style="margin-left:2px;" value="领导审核" onclick="declaration();" />
					</s:if>
					<s:if test="accessRight.indexOf('B')!=-1">
						<input type="button" style="margin-left:2px;" value="领导退回" onclick="untread();" />
					</s:if>
					<s:if test="accessRight.indexOf('O')!=-1">
						<input type="button" style="margin-left:2px;" value="导出" onclick="exportTable();" />
					</s:if>
					<s:if test="accessRight.indexOf('V')!=-1">
						查询条件：根据&nbsp;&nbsp;<select style="width: 94px;" id="condition" onblur="acstatusValueBeChosen()">
	  						<option value="acname" selected="selected">资产名称</option>
							<option value="acstatus">资产状态</option>
							<option value="reportdepartment">申报部门</option>
	  					</select>
	  					
	  					<input type="text" class="qryTxt" id="conditionValue" />
	  					
	  					<select style="display: none;width: 150px" class="qryTxt" id="acstatusValue">
	  						<option value="131" selected="selected">申报-局领导已审核</option>
							<option value="201">入库-物资部经办已确认</option>
							<option value="202">入库-物资部经办已上报</option>
							<option value="203">入库-物资部领导已审核</option>
	  					</select>
	  					
	  					<input type="button" style="margin-left:1px;" value="查询" onclick="selectAssetCart()"/>
					</s:if>
				</td>
			</tr>
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
						  <td width="3%"><input id="checkAll" type="checkbox" /></td>
						  <td width="6%">资产名称</td>	
						  <td width="5%">资产简称</td>
						  <td width="5%">申报原因</td>
						  <td width="5%">资金来源</td>
						  <td width="5%">凭证编号</td>
						  <td width="5%">会计科目</td>
						  <td width="6%">申请部门</td>
						  <td width="5%">资产规格</td>
						  <td width="7%">生产日期</td>
						  <td width="4%">使用期限</td>
						  <td width="7%">预计停用日期</td>
						  <td width="7%">实际停用日期</td>
						  <td width="5%">单价</td>
						  <td width="5%">计量单位</td>
						  <td width="5%">生产厂家</td>
						  <td width="10%">资产状态</td>
						</tr>
						
						<s:iterator var="ac" value="pagination.dataList" status="sta"> 
						<tr class="dataRow" id="<s:property value='#ac.acid'/>">
						  <td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid' />" /></td>
						  
						  <td><s:property value="#ac.acname" /></td>
						  <td><s:property value="#ac.acanothername"/></td>
						  <td><s:property value="#ac.reportreason"/></td>
						  <td><s:property value="#ac.assetcomefrom"/></td>
						  <td><s:property value="#ac.orderid"/></td>
						  <td><s:property value="#ac.accountsubject"/></td>
						  <td><s:property value="#ac.reportdepartment"/></td>
						  <td><s:property value="#ac.category.catnorms"/></td>
						  <td>
						    <fmt:formatDate value="${producedate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.lifetime"/></td>
						  <td>
						     <fmt:formatDate value="${planstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td>
						     <fmt:formatDate value="${actualstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.reportprice"/></td>
						  <td><s:property value="#ac.category.catunit"/></td>
						  <td><s:property value="#ac.producer"/></td>
						  <td>
						  	<s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						       		<s:if test='#ac.acstatus=="131"'>
						       			<div style="color: #000000;"><s:property value="desc" /></div>
						       		</s:if>
						       		<s:elseif test='#ac.acstatus=="201"'>
						       			<div style="color: #ff0000;"><s:property value="desc" /></div>
						       		</s:elseif>
						       		<s:elseif test='#ac.acstatus=="202"'>
						       			<div style="color: #ffa500;"><s:property value="desc" /></div>
						       		</s:elseif>
						       		<s:elseif test='#ac.acstatus=="203"'>
						       			<div style="color: #00ff00;"><s:property value="desc" /></div>
						       		</s:elseif>
						       </s:if>
						     </s:iterator>
						   </td>
						</tr>
						</s:iterator>
     				</table>
     			</td>
     		</tr>
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
     	</table>
    </div>
</div>
  
  <script type="text/javascript">
  	//刷新
	function refresh(){
		location.href="getAllWarehonseAssetCard.action?FN=<s:property value='FN' />";
	}
	//明细
	function particular(){
		var allWhAssetCard = $("input:checked");
	    if(allWhAssetCard.length == 0){
    		alert("你还没有选择要查看明细值的资产");
	    }else if(allWhAssetCard.length == 1){
	    	location.href = "getAssetCardById.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value;
	    }else{
	    	alert("每次只能查看一个资产明细值");
		}
	}
	//经办确认
	function validate(){
		var allWhAssetCard = $("input:checked");
		var str="";
		if(allWhAssetCard.length == 0){
			alert("请选择");
		}else{
			for(var i=0;i<allWhAssetCard.length;i++){
				str=str+allWhAssetCard[i].value+",";
			}
			location.href = "updateAssetCardValidate.action?FN=<s:property value='FN' />&acidAll="+str;
		}
	}
	//经办上报
	function report(){
		var allWhAssetCard = $("input:checked");
		var str="";
		if(allWhAssetCard.length == 0){
			alert("请选择");
		}else{
			for(var i=0;i<allWhAssetCard.length;i++){
				str=str+allWhAssetCard[i].value+",";
			}
			location.href = "updateAssetCardReport.action?FN=<s:property value='FN' />&acidAll="+str;
		}
	}
	//领导审核
	function declaration(){
		//需要弹出对话框要求输入审核通过的原因
		var allWhAssetCard = $("input:checked");
	    if(allWhAssetCard.length == 0){
    		alert("请选择");
	    }else if(allWhAssetCard.length == 1){
	    	var vRValue=showdepartment();
	    	if(vRValue == undefined){
				ideaValue="操作人按了取消键";
			}else if(vRValue==''){
				ideaValue="操作人没有输入审批意见";
				location.href = "updateAssetCardDeclaration.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
			}else{
				location.href = "updateAssetCardDeclaration.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
			}
	    }else{
	    	alert("每次只能审核操作一个资产");
		}
	}
	//退回
	function untread(){
		//需要弹出对话框要求输入退回的原因
		var allWhAssetCard = $("input:checked");
	    if(allWhAssetCard.length == 0){
    		alert("请选择");
	    }else if(allWhAssetCard.length == 1){
	    	var vRValue=showdepartment();
	    	if(vRValue == undefined){
				ideaValue="操作人按了取消键";
			}else if(vRValue==''){
				ideaValue="操作人没有输入审批意见";
				location.href = "updateAssetCardUntread.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
			}else{
				location.href = "updateAssetCardUntread.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
			}
	    }else{
	    	alert("每次只能退回操作一个资产");
		}
	}
	//导出
	function exportTable(){
		if(confirm("确定要导出所有记录吗?")){
			location.href="excelToolAssetCard.action?FN=<s:property value='FN' />";
		} 
	}
	//条件查询
	function selectAssetCart(){
		var property=document.getElementById("condition");
		var propertyValue=property.options[property.selectedIndex].value;
		if(propertyValue=="acstatus"){
			var propertyBeChoose=document.getElementById("acstatusValue");
			var propertyValueBeChoose=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;
			location.href = "getWarehonseAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&propertyValueBeChoose="+propertyValueBeChoose;
		}else{
			var inputValue=document.getElementById("conditionValue").value;
			location.href = "getWarehonseAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&inputValue="+inputValue;
		}
	}
	//显示意见输入页面
	function showdepartment(){
		var vRValue = window.showModalDialog("page/daily/idea.jsp",null,"dialogWidth=320px;dialogHeight=450px;status=0;scroll=0");
		return vRValue;
	}
	//条件选择
	function acstatusValueBeChosen(){
		var property=document.getElementById("condition");
		var conditionValue=document.getElementById("conditionValue");
		var acstatusValue=document.getElementById("acstatusValue");
		if(property.options[property.selectedIndex].value=="acstatus"){
			conditionValue.style.display="none";	
			acstatusValue.style.display="inline";
		}else{
			conditionValue.style.display="inline";	
			acstatusValue.style.display="none";
		}
	}
	</script>
	</body>
</html>
